<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: table_common_admincp_cmenu.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

class table_home_bannerpic extends discuz_table
{
	public function __construct() {

		$this->_table = 'home_bannerpic';
		$this->_pk    = 'id';

		parent::__construct();
	}

	public function get_all_pic(){
		return  DB::fetch_all('select * from %t',array($this->_table));
	}

	public function get_show_pic(){
		return DB::fetch_all('select * from %t where is_show=1',array($this->_table));
	}

	public function get_pic_by_id($pid){
		return DB::fetch_first('select * from %t where pid=%d',array($this->_table,$pid));
	}

	public function add_bannerpic($path,$file_name){
		return DB::query('insert into %t (img_path,img_name) values(%p,%s)',array($this->_table,$path,$file_name));
	}

	public function update_pic($pid,$opt,$val){
		if($opt=='del'){
			return DB::query('delete from %t where pid=%d',array($this->_table,$pid));
		} else{
			if($opt!='')
				return DB::query('update %t set is_show=%d,img_url=%s where pid=%d',array($this->_table,$opt,$val,$pid));
			else
				return DB::query('update %t set img_url=%s where pid=%d',array($this->_table,$val,$pid));
		}
	}

}

?>